package com.iwayin.web.action.setting;

import com.iwayin.core.bo.setting.EmailSettingBO;
import com.iwayin.core.common.Constants;
import com.iwayin.core.dataobject.EmailSettingDO;
import com.iwayin.web.action.BaseAction;
import com.iwayin.web.common.AjaxResult;

public class EmailSettingAction extends BaseAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = -6145520300399978994L;
	
	private EmailSettingBO emailSettingBO;
	private EmailSettingDO emailSetting;
	private AjaxResult ajaxResult;
	
	public String viewEmailSetting(){
		emailSetting = emailSettingBO.getEmailSetting(this.getLoginUser().getId());
		return SUCCESS;
	}
	
	public String updateEmailSetting(){
		try {
			emailSetting.setUserId(this.getLoginUser().getId());
			emailSettingBO.updateEmailSetting(emailSetting);
			ajaxResult = AjaxResult.succResult();
		} catch (Exception e) {
			ajaxResult = AjaxResult.errorResult(Constants.DEFAULT_SYSTEM_ERROR_MSG);
		}
		return SUCCESS;
	}

	public void setEmailSettingBO(EmailSettingBO emailSettingBO) {
		this.emailSettingBO = emailSettingBO;
	}

	public EmailSettingDO getEmailSetting() {
		return emailSetting;
	}

	public void setEmailSetting(EmailSettingDO emailSetting) {
		this.emailSetting = emailSetting;
	}

	public AjaxResult getAjaxResult() {
		return ajaxResult;
	}

}
